app.controller('goodsAuditInfoCtrl',['$scope','$stateParams','utilService','goodsAuditInfoService','toaster',function ($scope,$stateParams,utilService,goodsAuditInfoService,toaster) {

    $scope.id=$stateParams.id;
    $scope.goods;

    $scope.findByIdForOther=function(){
        goodsAuditInfoService.findByIdForOther($scope).then(function(result){
            switch (result.status){
                case 200:
                    $scope.goods=result.data;
                    break;
                case 646:
                    toaster.pop('waiting', "提示", result.message);
                    $state.go('app.404');
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        })
    }

    $scope.findByIdForOther();


    //查询商品图片
    $scope.coverImages=[];
    $scope.cardImages=[];
    $scope.detailImages=[];
    $scope.commendImages=[];

    $scope.findByGoodsId=function(){
        goodsAuditInfoService.findByGoodsId($scope).then(function(result){
            switch (result.status){
                case 200:
                    if(result.data==null){
                        return;
                    }

                    if(!angular.isUndefined(result.data['0'])){
                        $scope.coverImages=result.data['0'];
                    }

                    if(!angular.isUndefined(result.data['1'])){
                        $scope.cardImages=result.data['1'];
                    }

                    if(!angular.isUndefined(result.data['2'])){
                        $scope.detailImages=result.data['2'];
                    }

                    if(!angular.isUndefined(result.data['3'])){
                        $scope.commendImages=result.data['3'];
                    }

                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        })
    }

    $scope.findByGoodsId();

    //查询skuContent
    $scope.findAllByGoodsId = function(){
        utilService.queryForPagingList($scope,{
            url:$scope.app.domain + 'goodssku/goodsid',
            params:{goodsId:$scope.id}
        }).then(function(result){
        });
    }

    $scope.findAllByGoodsId();

}])